﻿using GrainManage.Core.Access;
using GrainManage.Core.Access.Interfaces;
using GrainManage.Core.Provider;
using GrainManage.Core.Provider.Interfaces;
using GrainManage.Core.Service;
using GrainManage.Core.Service.Interfaces;
using System.Configuration;

namespace GrainManage.Server
{
    public class ObjectFactory
    {
        private static IAccess DbAccessor
        {
            get
            {
                string connectionString = ConfigurationManager.ConnectionStrings["GrainManageConnectionString"].ConnectionString;
                IProvider provider = new MySqlProvider(connectionString);
                IAccess accessor = new ProcAccess(provider, new CachedParameterBuilder(provider));
                return accessor;
            }
        }

        public static IAccountService AccountService { get { return new AccountService(DbAccessor); } }
        public static IColumnService ColumnService { get { return new ColumnService(DbAccessor); } }
        public static ICommonService CommonService { get { return new CommonService(DbAccessor); } }
        public static IContactService ContactService { get { return new ContactService(DbAccessor); } }
        public static IDistrictService DistrictService { get { return new DistrictService(DbAccessor); } }
        public static IImageService ImageService { get { return new ImageService(DbAccessor); } }
        public static IPriceService PriceService { get { return new PriceService(DbAccessor); } }
        public static IStatusService StatusService { get { return new StatusService(DbAccessor); } }
        public static ITradeService TradeService { get { return new TradeService(DbAccessor); } }
        public static ITypeService TypeService { get { return new TypeService(DbAccessor); } }
        public static IWeatherService WeatherService { get { return new WeatherService(DbAccessor); } }
    }
}